Strict

Import agfx

Global myTmpScreen:TTmpScreen

Class TAgfx_test_app Extends TFramework

	Method OnCreate:Int()
		

		Super.OnCreate()

		Self.fps_On = True
		myTmpScreen = New TTmpScreen		
		myTmpScreen.Prepare()
		
		
		
		Return 0
	End
	
End

Class myTGestureRecorder Extends TGestureRecorder
	
	Field sprite:TSprite
	Field state:Int = 0
	Field targets:TGesturePoint[]
	Field move_state:Int=0
	Field next_target_id:Int = 0
	
	Method OnRelease:Void()
		Self.state = 1
		Self.targets = Self.GetAsArray()
		Self.sprite.position.Set(Self.targets[0].position)
		Self.sprite.speed = Self.GetSpeed()*2.0
		Self.move_state = 1
		Self.next_target_id = 1
	End Method

	
	Method myUpdate:Void()
		Local IsEnd:Bool
		If Self.move_state=1 Then			
			IsEnd = Self.sprite.MoveTo(Self.targets[Self.next_target_id].position)
			
			if IsEnd and Self.next_target_id<self.count-2 then				
				Self.next_target_id +=1
			Else
				If Self.next_target_id=self.count-2 Then Self.move_state = 0
			EndIf
			
		EndIf
		
		Self.sprite.Update()
	End
	
	Method myRender:Void()
		Self.sprite.Draw()
	End Method
	
End Class

Class TTmpScreen Extends TScreen
	
	Field path:myTGestureRecorder
	Field txt:String = "GM_LINE"
	
	Method Start:Void()
	
		IMAGES.Load("sprite.png","ARROW")
		IMAGES.Dump()
	
		Self.path = New myTGestureRecorder	
		
		Self.path.draw_on=True
		Self.path.mode=GM_LINE
		
		Self.path.sprite = New TSprite("ARROW_01",IMAGES.Find("ARROW"),320,240)
		 
		
	End
	
	' main app logic loop update
	Method Update:Void()
	
		Self.path.Update()
		Self.path.myUpdate()

		If KeyHit(KEY_1) Then
			Self.path.mode = GM_LINE
			Self.txt = "GM_LINE"
		End

		If KeyHit(KEY_2) Then		
			Self.path.mode = GM_LINES	
			Self.txt = "GM_LINES"
		End
		
		
		If KeyHit(KEY_3) Then
			Self.path.mode = GM_SPLINES
			Self.txt = "GM_SPLINES"
		End
		

	End
	
	' main app render loop
	Method Render:Void()
		Cls
		Self.path.Render()
		Self.path.myRender()

		DrawText("[1] GM_LINE",0,20)
		DrawText("[2] GM_LINES",0,40)
		DrawText("[3] GM_SPLINES",0,60)

		DrawText(txt,0,80)
		
	End
End



